<script setup lang="ts">
import { useRouter } from 'vue-router';
import useUserStore from '@/store/modules/user';
import { ArrowDown } from '@element-plus/icons-vue';


const useUser = useUserStore()
const $router = useRouter()

const goHome = () => {
  // 点击跳转
  $router.push({ path: '/home' })
}

const login = () => {
  
  useUser.visiable = true
}

const logout = () => {
  // 点击退出登录
  useUser.logout()
  $router.push('/home')
}

const certification =() => {
  $router.push({path:'/user/certification'})
}

const order =() => {
  $router.push({path:'/user/order'})
}

const patient =() => {
  $router.push({path:'/user/patient'})
}
</script>



<template>
  <div class="top">
    <div class="content">
      <!-- 左侧内容 -->
      <div class="left" @click="goHome">
        <img src="../../assets/images/logo.png" alt="">
        <p>尚医通 预约挂号统一平台</p>
      </div>

      <!-- 右侧内容 -->
      <div class="right">
        <p class="help">帮助中心</p>
        <p class="login" @click="login" v-if="!useUser.userInfo.userName">登录/注册</p>
        <el-dropdown v-else>
          <span class="el-dropdown-link">
            {{ useUser.userInfo.userName }}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="certification">实名认证</el-dropdown-item>
              <el-dropdown-item @click="order">挂号订单</el-dropdown-item>
              <el-dropdown-item @click="patient">就诊人管理</el-dropdown-item>
              <el-dropdown-item divided @click="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>

      </div>
    </div>
  </div>
</template>



<style scoped lang="scss">
.top {
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 70px;
  background-color: #fff;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid #cabebe;

  .content {
    // background-color: pink;
    width: 1200px;
    height: 70px;
    display: flex;
    justify-content: space-between;

    .left {
      display: flex;
      justify-content: center;
      align-items: center;

      img {
        width: 50px;
        height: 50px;
        margin-right: 10px;
      }

      p {
        font-size: 20px;
        color: #55a6fe;
      }
    }

    .right {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #bbb;
      font-size: 14px;

      .help {
        margin-right: 10px;
      }

      .login:hover {
        cursor: pointer;
        color: #55a6fe;
      }

      .userName {
        color: black;
      }
    }
  }
}
</style>